package com.gin.kotlin.no_gay_alliance.provider.ngaphp

import com.gin.nga.main.NgaApi
import com.gin.nga.response.follow.FollowStatusData
import java.lang.ref.WeakReference

class FollowDynamicsProvider private constructor():AbstractCachedDataProvider<Int, FollowStatusData,FollowStatusData>(
    javaType = TYPE_FACTORY.constructType(FollowStatusData::class.java)
){
    override val dir=  "FOLLOW_DYNAMICS"

    override fun transform(rawData: FollowStatusData) = rawData

    override fun requestMethod(ngaApi: NgaApi, params: Int?)=ngaApi.followApi.dynamics(params)

    override fun obtainRelativePath(userId: Long, params: Int?) = "${userId}_$params.json"

        companion object {
            private var instance: WeakReference<FollowDynamicsProvider> = WeakReference(FollowDynamicsProvider())
            fun getInstance(): FollowDynamicsProvider = instance.get() ?: FollowDynamicsProvider().also { instance = WeakReference(it) }
        }
}